package com.guoyansoft.model.service.impl;

import com.guoyansoft.config.R;
import com.guoyansoft.model.dao.AddressDao;
import com.guoyansoft.model.dao.CustomerAndAddressDao;
import com.guoyansoft.model.pojo.Customer;
import com.guoyansoft.model.pojo.CustomerAndAddress;
import com.guoyansoft.model.service.CustomerAndAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CustomerAndAddressServiceImpl implements CustomerAndAddressService {
    @Autowired
    private CustomerAndAddressDao customerAndAddressDao;
    @Autowired
    private AddressDao addressDao;
    @Override
    public R queryAll() {
        List<CustomerAndAddress> customerAndAddressList = customerAndAddressDao.selectAll();
        return R.suc(customerAndAddressList);
    }

    @Override
    public R save(CustomerAndAddress customerAndAddress) {
        int row = customerAndAddressDao.insert(customerAndAddress);
        return R.suc(row);
    }


    @Override
    public R queryByCustomerId(Integer customerId) {
        List<CustomerAndAddress> customerAndAddresses = customerAndAddressDao.selectByCustomerId(customerId);
        return R.suc(customerAndAddresses);
    }

}
